package service

import (
	"awesomeProject/app/model"
	"awesomeProject/app/request"
	"awesomeProject/app/response"
	"awesomeProject/global"
	"context"
	"go.mongodb.org/mongo-driver/bson"
)

type DeliverPlaceSrv struct{}

func (r *DeliverPlaceSrv) QueryList(req request.DeliverPlaceList) response.Resp {
	var places []model.DeliverPlace
	cursor, err := global.MongoDB.Collection("deliver_places").Find(context.Background(), bson.D{})
	if err != nil {
		return response.ErrQuery
	}
	if err = cursor.All(context.TODO(), &places); err != nil {
		return response.ErrQuery
	}

	return response.OK.WithData(places)
}
